package com.taobao.home.feignclient;

import com.taobao.base.model.RestResponse;
import com.taobao.home.model.dto.GoodsDetailsDto;
import com.taobao.home.model.dto.GoodsPreviewDto1;
import com.taobao.home.model.po.Goods;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.io.IOException;
import java.util.List;

/**
 *远程调用搜索接口
 */
//使用fallback定义降级类是无法拿到熔断异常,使用FallbackFactory可以拿到熔断的异常信息
@FeignClient(name = "search",fallbackFactory = SearchServiceClientFallbackFactory.class)
public interface SearchServiceClient {

    /**
     * 添加文档
     */
    @PostMapping("/search/addDoc")
     RestResponse<String> addDoc(@RequestBody Goods goods) throws IOException;


    @GetMapping("/search/test/{goodsId}")
     RestResponse<String> test(@PathVariable("goodsId") int goodsId);

    /**
     * 商品详情
     * 匹配查询
     */
    @GetMapping("/search/searchByTitle/{title}")
     RestResponse<List<GoodsDetailsDto>> goodsDetailsByTitle(@PathVariable("title") String title);

    /**
     * 根据title查询搜素结果页商品
     */
    @GetMapping("/search/getGoodsPreviewByTitle/{title}")
    RestResponse<List<GoodsPreviewDto1>> getGoodsPreviewByTitle(@PathVariable("title") String title) ;


}
